<template>
    <rx-layout>
        <div slot="center" style>
            <rx-fit>
                <rx-grid
                    ref="table"
                    :allowRowSelect="true"
                    :multiSelect="true"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-form/form/core/formExecuteLog/getExecuteLog"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    id-field="batch"
                    @selectChange="onSelectChange"
                >
                     <span slot="status" slot-scope="{ text, record }">
                          <a-tag :color="statusMap[text].color">
                            <span>{{ statusMap[text].text }}</span>
                          </a-tag>
                    </span>
                     <span slot="action" slot-scope="{ text, record }" class="actionIcons">
                        <span @click.stop="getExecuteLog(record)">{{$ti18('rxList.detailBtn','明细')}}</span>
                    </span>
                </rx-grid>
            </rx-fit>
        </div>
    </rx-layout>
</template>

<script>
import FormExecuteLogApi from '@/api/form/core/formExecuteLog'
import FormExecuteLogEdit from './FormExecuteLogEdit'
import {BaseList, RxFit, RxGrid,Util} from "@lowcode/jpaas-common-lib";

export default {
    name: 'FormExecuteLogList',
    mixins: [BaseList],
    components: {
        RxFit
    },
    props:["instId"],
    data() {
        return {
            columns: [
                {title: this.$ti18('rxList.index','序号'), type: 'indexColumn', width: 100, dataIndex: 'serial', scopedSlots: {customRender: 'serial'}},
                {title: this.i18n('form.executor','执行人'), dataIndex: 'createByName', width: 100},
                {title: this.i18n('form.exeTime','执行时间'), dataIndex: 'createTime', width: 100},
                {title: this.$ti18('rxList.action','操作'), width: 100, dataIndex: 'action', scopedSlots: {customRender: 'action'}}
            ],
            statusMap: {
                '1': {color: 'green', text: this.i18n('statusMap.success','成功')},
                '0': {color: 'red', text: this.i18n('statusMap.failure','失败')},
            }
        }
    },
    created() {
        if(this.instId){
           this.queryParam["Q_INST_ID__S_EQ"]=this.instId;
        }
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"FormExecuteLog",key);
        },
        delById(ids) {
            return FormExecuteLogApi.del({ids: ids.join(',')});
        },
        getListByParams(parameter) {
            return FormExecuteLogApi.query(parameter)
        },
        getExecuteLog(record){
            var conf = {
                component: FormExecuteLogEdit,
                curVm: this,
                max:true,
                title: this.i18n('list.exeRecordDetail','执行记录详情'),
                data: {
                    batch:record.batch
                },
            }
            var self = this;
            Util.open(conf, function(action,data) {
                if(action!='ok')return;

            })
        }
    }
}
</script>
<style scoped>

</style>

